//
//  ToggleIconButton.swift
//  xgwjinterconnection
//  自定义状态切换按钮
//  Created by WangWeiShuo on 2025/8/19.
//

import SwiftUI

struct ToggleIconButton: View {
    // 用于跟踪按钮状态的变量
    var iconNormal : String = ""
    var iconPressed : String = ""
    var isPressed = false
    let action: () -> Void
    
    var body: some View {
        Button(action: action){
            // 根据状态显示不同图标
            Image(isPressed ? iconPressed : iconNormal)
                .resizable()
                .scaledToFit()
                .animation(.easeInOut, value: isPressed) // 添加过渡动画
        }
    }
}
